/*
 *  Copyright 2015-2016, RenGu Technology (BeiJing) Co., Ltd.
 *  All right reserved.
 *
 *  THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF RENGU TECHNOLOGY (BeiJing) CO., LTD.
 *
 *  THE CONTENTS OF THIS FILE MAY NOT BE DISCLOSED TO THIR PARTIES,
 *  COPIED OR DUPLICATED IN ANY FORM, IN WHOLE OR IN PART,
 *  WITHOUT THE PRIOR WRITTEN PERMISSION OF RENGU TECHNOLOGY (BeiJing) CO., LTD.
 *
 *  CheckCutDayUtil
 *
 *  Edit History:
 *      lizhangtao Created on 2020年04月13日
 *
 */
package cc.rengu.igas.acct.common.util;

import cc.rengu.igas.acct.common.dao.AcctDayCutInfoMapper;
import cc.rengu.igas.acct.common.dao.impl.AcctDayCutInfoMapperImpl;
import cc.rengu.igas.acct.common.entity.AcctDaycutInfo;
import cc.rengu.igas.acct.common.enums.AcctRespCodeEnum;
import cc.rengu.oltp.service.model.BizException;
import cc.rengu.oltp.utility.util.DbsUtil;

/**
 * 检查日切
 *
 * @author lizhangtao
 * @version 1.0
 * @date 2020/5/8
 */
public class CheckCutDayUtil {

    /**
     * 检查切记获取当前记账日期
     *
     * @param instId 机构号
     * @return 成功返回当前账务日期yyyyMMdd
     * @throws BizException 无数据或者其他失败异常都抛出异常
     */
    public static String check(String instId, DbsUtil dbsUtil) throws BizException {
        AcctDayCutInfoMapper acctDayCutInfoMapper = new AcctDayCutInfoMapperImpl();
        AcctDaycutInfo acctDaycutInfo = acctDayCutInfoMapper.selectAcctDayCutInfoByInstId(instId, dbsUtil);
        if (null == acctDaycutInfo) {
            throw new BizException(AcctRespCodeEnum.DAY_CUTTING_ERROR.getRespCode(),
                    AcctRespCodeEnum.DAY_CUTTING_ERROR.getRespDesc());
        } else {
            return acctDaycutInfo.getAcctDate();
        }
    }
}
